package com.itheima.day08_api;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * 菜品管理类，提供**上架菜品的功能、浏览菜品的功能、展示操作界面的功能。**
 */
public class FoodManager {
    private ArrayList<Food> foods = new ArrayList<Food>();
    private Scanner sc = new Scanner(System.in);

    /**
     * 添加菜品
     */
    public void addFood() {
        System.out.println("菜品上架");
        //2.创建Food对象
        Food food = new Food();
        System.out.println("请输入菜品名称：");
        String name = sc.next();
        food.setName(name);

        System.out.println("请输入菜品的原价：");
        double originalPrice = sc.nextDouble();
        food.setOriginalPrice(originalPrice);

        System.out.println("请输入菜品的特价：");
        double specialPrice = sc.nextDouble();
        food.setSpecialPrice(specialPrice);

        System.out.println("请输入菜的简介：");
        String info = sc.next();
        food.setInfo(info);
        foods.add(food);
        System.out.println("添加成功！");
    }
    /**
     * 显示所有菜品
     */
    public void showAllFoods() {
        System.out.println("所有菜品如下：");
        for (int i = 0; i < foods.size(); i++) {
            Food food = foods.get(i);
            System.out.println(food.getName() + "  " + food.getOriginalPrice() + "  " + food.getSpecialPrice() + "  " + food.getInfo());
        }
    }
    /**
     * 显示操作界面
     */
    public void showMenu() {
        while (true) {
            System.out.println("欢迎来到点餐系统");
            System.out.println("1. 添加菜品");
            System.out.println("2. 显示所有菜品");
            System.out.println("3. 退出系统");
            System.out.println("请输入您的选择：");
            int command = sc.nextInt();
            switch (command) {
                case 1:
                    addFood();
                    break;
                case 2:
                    showAllFoods();
                    break;
                case 3:
                    System.out.println("谢谢使用！");
                    System.exit(0);
                default:
                    System.out.println("您输入的命令有误，请重新输入！");
            }
        }
    }

}
